/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 *
 * Author: zhaosj
 * Date: 2011-3-14 下午05:23:21
 */
package com.test;

/**
 * @author zhaosj
 * 
 */
public class Synchronized implements Runnable {

	// public class TT implements Runnable {
	int b = 100;

	public synchronized void m1() throws Exception {

		System.out.println("m1 b ==== "+b);
		b = 1000;
		Thread.sleep(5000);
		System.out.println("m1 wake " + b);
	}

	public synchronized void m2() throws Exception {
		Thread.sleep(2500);
		System.out.println("m2 wake "+b);
		b = 2000;
	}

	public void run() {
		try {
			m1();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) throws Exception {
		Synchronized tt = new Synchronized();
		Thread t = new Thread(tt);
		t.start();

		tt.m2();
		System.out.println("m2 = "+tt.b);
	}
}
